
	/* stupid function */
	function deleteDiv(div){
		alert("don't use me!");
	//$("#"+div).remove();
	}
	
	(function($) {
    $.fn.fadeAndDisable = function(delay) {
        delay = delay || 500;
        return this.each(function() {
            $(this).fadeTo(0.5, delay, function() {
                $(this).attr('disabled', 'disabled');
            })
        });
    }

    $.fn.fadeAndEnable = function(delay) {
        delay = delay || 500;
        return this.each(function() {
            $(this).fadeTo(1, delay, function() {
                $(this).removeAttr('disabled');
            })
        });
    }
	   
	$.fn.disableButton = function(delay) {
        return this.each(function() {
            $(this).attr('disabled', 'disabled');
            $(this).addClass('disabled');
            $(this).removeClass('positive');
            $(this).removeClass('negative');
			
        });
    }

})(jQuery);
	function disableButton(obj){
		$(obj).attr('disabled', 'disabled');
		$(obj).addClass('disabled');
		$(obj).removeClass('positive');
		$(obj).removeClass('negative');
	}
	
	// LOVE LOVE THIS ONE
function createForm(id,postParam){
	el = $('#'+id);
	link = el.next("div");
	link.hide();
	//alert(link.constructor.toString());
	text = el.text() ;
	/*el.before("<form method='post' style='display:inline-block;' action=''><div><input type='text' name='value' value='"+text+"' size="+text.length+"/><input type='hidden' name='"+postParam+"' value="+id+" />");
	el.after("<span onclick=\"$('#"+id+"').prev('form').submit();\"><img src='img/icons/accept.png' alt='Accepter' />bla</span><span onclick=\"window.location.reload();\"><img src='img/icons/cancel.png'  alt='Annuler' /></span></div></form>");*/
	el.replaceWith("<form method='post' style='display:inline-block;' action=''><div><input type='text' name='value' value='"+text+"' size="+text.length+"/><input type='hidden' name='"+postParam+"' value="+id+" /><span onclick=\"$('#"+id+"').prev('form').submit();\"><img src='img/icons/accept.png' alt='Accepter' onclick=\"$(this).parents('form').submit();\"/></span><span onclick=\"window.location.reload();\"><img src='img/icons/cancel.png'  alt='Annuler' /></span></div></form>");
	el.hide();
}
// pour listes matieres par exemple
function activateToggles() {	
	$(".toggle").click(function() {
	  if ($(this).parent().children().length == 2)
		$(this).next("div").toggle('fast');
	  else
	  {
		//$(this).parent().wrapInner("<div>");
		//$(this).parent().append("<div></div>");
		//$(this).appendTo($(this).parent());
		//$(this).appendTo($(this).parent().parent());
		$(this).next("div").toggle('fast');
	  }
	  // Image switch
	  //alert($(this).children("a").find("img").attr("src"))
	  if( $(this).find("img").attr("src") == "img/icons/bullet_toggle_plus.png" ){
		$(this).children("a").find("img").attr("src","img/icons/bullet_toggle_minus.png") ;
	  } else {
		$(this).children("a").find("img").attr("src","img/icons/bullet_toggle_plus.png") ;} 
	});
}

function activateHoverButtons(){
	// Initial toggle
	$('.hoverButton').hide();
	
	$('.hoverTrigger').mouseover(function() {
		$(this).children('.hoverButton').fadeIn('fast');
	});
	$('.hoverTrigger').mouseleave(function() {
		$(this).children('.hoverButton').fadeOut('fast');
	});
}